<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript">
        $(function(){
            var $btn = $("#btn");
            var $btn1 = $("#btn1");
            $btn.on("click",function(){
                var name = $("#name").val();
                $.ajax({
                    type : 'post',
                    url : './WSServlet',
                    data : {
                        name : name
                    },
                    success : function(msg){
                        var $msg = $(msg);
                        var $entry = $msg.find("entry");
                        var key = $entry.find("key").text();
                        var value = $entry.find("value").text();
                        console.log(key+":"+value);
                    }
                });
            });
            $btn1.on("click",function(){
                var name = $("#name").val();
                var content = $("#content").val();
                $.ajax({
                    type : 'post',
                    url : './SayHello',
                    data : {
                        name : name,
                        content : content
                    },
                    success : function(msg){
                        var $msg = $(msg);
                        var value = $msg.find("return").text();
                        console.log(value);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <input id="name"><br/>
    <input id="content"><br/>
    <input type="button" id="btn" value="getName">
    <input type="button" id="btn1" value="sayHello">
</body>
</html>
